﻿using HDS.IService.Master;
using HDS.Model;
using HDS.Model.Entity.View;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HDS.Admin.Api.Controllers
{
    [Route("[controller]/[action]")]
    [ApiController]
    [EnableCors]
    public class StatisticController : Controller
    {
        private readonly ILogger<StatisticController> _ILogger;

        private readonly IStatisticService _IStatisticService;

        public StatisticController(ILogger<StatisticController> logger, IStatisticService istatisticService)
        {
            _ILogger = logger;
            _IStatisticService = istatisticService;
        }

        public async Task<ResultData<List<VSaleStatistic>>> GetTotalSale(DateTime date, string currency)
        {
            var list = await _IStatisticService.GetAllSaleStatistic(date, currency);
            return new ResultData<List<VSaleStatistic>> { Success = true, Data = list };
        }

        public async Task<ResultData<List<VSaleStatistic>>> GetTotalSaleDaily(DateTime date, string currency)
        {
            var list = await _IStatisticService.GetDailySaleStatistic(date, currency);
            return new ResultData<List<VSaleStatistic>> { Success = true, Data = list };
        }
    }
}
